package org.nokatag.code;

public abstract class AbstractTransformImageOp extends AbstractImageOp
{

    private boolean initialized;

    protected abstract void transform(int i, int j, double ad[]);

    protected void init()
    {
    }

    public AbstractTransformImageOp()
    {
        setEdgeMode(2);
    }

    protected void filter(int inPixels[], int outPixels[], int width, int height)
    {
        if(!initialized)
        {
            init();
            initialized = true;
        }
        long time1 = System.currentTimeMillis();
        double t[] = new double[2];
        for(int y = 0; y < height; y++)
        {
            for(int x = 0; x < width; x++)
            {
                transform(x, y, t);
                int pixel = getPixelBilinear(inPixels, t[0], t[1], width, height, getEdgeMode());
                outPixels[x + y * width] = pixel;
            }

        }

        long time2 = System.currentTimeMillis() - time1;
    }
}
